Skip to content

*: use buf as formatter#1422

Open
lance6716 wants to merge 1 commit intorelease-8.5from
lance6716/port-buf-formatter-to-8.5
Open

*: use buf as formatter#1422
lance6716 wants to merge 1 commit intorelease-8.5from
lance6716/port-buf-formatter-to-8.5

Conversation

@lance6716
Copy link
Contributor

@lance6716 lance6716 commented Feb 26, 2026

After about a month, TiDB has upgraded kvproto to the version after #1408, and performance regression test does not show any problems. So I think we have confidence that the formatter is not harmful.

To reduce conflicts whtn cherry-pick PR from master branch to release-8.5, I propose that we also add the formatter to release-8.5


this PR can be reproduced by

  1. cherry-pick script file changes from master PR *: use buf as formatter #1408
image
git show e75b531a1914ff517d3945ac61ca93072db242c4 -- Makefile scripts/proto_format.sh scripts/common.sh scripts/generate_cpp.sh .editorconfig README.md | git apply --3way 

for scripts/check.sh file, there's a conflict. So manually edit like

diff --git i/scripts/check.sh w/scripts/check.sh
index d6c982c..48878a3 100755
--- i/scripts/check.sh
+++ w/scripts/check.sh
@@ -1,5 +1,11 @@
 #!/usr/bin/env bash
 
+PROGRAM=$(basename "$0")
+SCRIPTS_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
+KVPROTO_ROOT=$(cd "${SCRIPTS_DIR}/.." && pwd)
+
+cd "${KVPROTO_ROOT}"
+
 check_protoc_version() {
     version=$(protoc --version | awk '{print $NF}')
     major=$(echo ${version} | cut -d '.' -f 1)
@@ -16,6 +22,10 @@ check_protoc_version() {
     return 1
 }
 
+check-protos-format() {
+    "${SCRIPTS_DIR}/proto_format.sh" --check
+}
+
 check-protos-compatible() {
     GOPATH=$(go env GOPATH)
     if [ -z $GOPATH ]; then
@@ -47,6 +57,6 @@ check-protos-compatible() {
     return 0
 }
 
-if ! check_protoc_version || ! check-protos-compatible; then
+if ! check_protoc_version || ! check-protos-format || ! check-protos-compatible; then
 	exit 1
 fi
  1. run formatter
make proto-fmt
  1. golang code generation
make go

Copilot AI review requested due to automatic review settings February 26, 2026 06:20
@ti-chi-bot ti-chi-bot bot requested a review from tangwz February 26, 2026 06:20
@ti-chi-bot ti-chi-bot bot added the size/XXL label Feb 26, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes .proto formatting across the repo by adopting buf format, updates CI/local checks to enforce the formatting, and applies the formatter output to existing proto sources (including regenerated Go outputs where applicable).

Changes:

  • Add a pinned buf-based formatter script plus make proto-fmt / make proto-fmt-check targets.
  • Update check/codegen scripts to incorporate formatting checks and handle buf’s multi-line option formatting for C++ generation.
  • Reformat many .proto files and update generated Go descriptor blobs accordingly.

Reviewed changes

Copilot reviewed 56 out of 61 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
scripts/proto_format.sh New pinned buf download + buf format runner for --check/--write.
scripts/check.sh Runs proto formatting check as part of make check; adds proto option checks (currently problematic).
scripts/common.sh Reworks clean_gogo_proto to strip gogoproto options robustly under buf formatting.
scripts/generate_cpp.sh Uses clean_gogo_proto per file after copying protos for C++ generation.
Makefile Adds proto-fmt and proto-fmt-check targets wired to the formatter script.
README.md Documents the new formatting workflow and how to fix formatting failures.
.editorconfig Enforces 2-space indentation for *.proto files in editors.
proto/tsopb.proto Reformatted via buf format.
proto/tracepb.proto Reformatted via buf format.
proto/schedulingpb.proto Reformatted via buf format.
proto/resource_usage_agent.proto Reformatted via buf format.
proto/resource_manager.proto Reformatted via buf format.
proto/replication_modepb.proto Reformatted via buf format.
proto/recoverdatapb.proto Reformatted via buf format.
proto/raft_serverpb.proto Reformatted via buf format.
proto/raft_cmdpb.proto Reformatted via buf format.
proto/mpp.proto Reformatted via buf format.
proto/metapb.proto Reformatted via buf format.
proto/meta_storagepb.proto Reformatted via buf format.
proto/logbackuppb.proto Reformatted via buf format.
proto/keyspacepb.proto Reformatted via buf format.
proto/import_kvpb.proto Reformatted via buf format.
proto/gcpb.proto Reformatted via buf format.
proto/errorpb.proto Reformatted via buf format.
proto/enginepb.proto Reformatted via buf format.
proto/encryptionpb.proto Reformatted via buf format.
proto/disk_usage.proto Reformatted via buf format.
proto/disaggregated.proto Reformatted via buf format.
proto/diagnosticspb.proto Reformatted via buf format.
proto/debugpb.proto Reformatted via buf format.
proto/deadlock.proto Reformatted via buf format.
proto/coprocessor.proto Reformatted via buf format (notably multi-line field options formatting).
proto/configpb.proto Reformatted via buf format.
proto/cdcpb.proto Reformatted via buf format.
proto/autoid.proto Reformatted via buf format.
include/rustproto.proto Reformatted via buf format.
include/eraftpb.proto Reformatted via buf format.
pkg/logbackuppb/logbackuppb.pb.go Updated generated descriptor blob due to proto formatting/re-ordering effects.
pkg/keyspacepb/keyspacepb.pb.go Updated generated descriptor blob due to proto formatting/re-ordering effects.
pkg/configpb/configpb.pb.go Updated generated descriptor blob due to proto formatting/re-ordering effects.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lance6716
Copy link
Contributor Author

Just to avoid the formatting causing some problems, I want to wait some weeks after master branch's merging before continue release branch formatting.

@lance6716 lance6716 closed this Mar 23, 2026
@lance6716 lance6716 force-pushed the lance6716/port-buf-formatter-to-8.5 branch from dc4a121 to bdcab1d Compare March 23, 2026 02:23
@ti-chi-bot ti-chi-bot bot added size/XS and removed size/XXL labels Mar 23, 2026
Signed-off-by: lance6716 <lance6716@gmail.com>
@lance6716 lance6716 reopened this Mar 23, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 23, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign bb7133, bornchanger, cfzjywxk, overvenus, rleungx, you06, yudongusa for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 23, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign bornchanger, cfzjywxk, overvenus, rleungx, tiancaiamao, you06, yudongusa for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added size/XXL and removed size/XS labels Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants